package com.gitee.xmhzzz.component.snowflake;

import com.gitee.xmhzzz.component.snowflake.core.snowflake.RedisWorkIdChoose;
import com.gitee.xmhzzz.component.spring.util.ApplicationContextUtil;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;

/**
 * 分布式 ID 自动装配
 *
 */
@Configuration
@Import(ApplicationContextUtil.class)
public class SnowflakeConfiguration {
    
    /**
     * 本地 Redis 构建雪花 WorkId 选择器
     */
    @Bean
    @ConditionalOnProperty("spring.redis.host")
    public RedisWorkIdChoose redisWorkIdChoose() {
        return new RedisWorkIdChoose();
    }
    

}
